home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / wild / support / pytree+.s < prev    next >
Text File  |  1999-01-01  |  1KB  |  52 lines

  1. ; PyTree macro: calcs the sqr of a number, using a scalable table.
  2. ; WARNING: NEGATIVE NUMBERS GIVE ABSURDE RESULTS! NO INTERNAL CHECK!
  3. ; Optimization 1. Eliminate cmps, use only a unique sub at start.
  4.  
  5. PyTree    MACRO    ;\1=x \2=Ax pointing to table \3=x^.5(result) \4=skratch
  6.     bra.b    cyc\@
  7. jump\@    move.l    (\2),\3
  8.     ble.b    fnd\@
  9.     lea.l    (\2,\3.l),\2
  10. cyc\@    move.l    (\2)+,\4
  11.     sub.l    \1,\4
  12.     beq.b    exact\@
  13.     blt.b    jump\@
  14.     tst.l    (\2)
  15.     bmi.b    fnd\@
  16.     addq.l    #8,\2
  17.     bra.b    cyc\@
  18. exact\@    move.l    4(\2),\3
  19.     bra.b    had\@
  20. fnd\@    addq.l    #4,\2
  21.     move.l    (\2)+,\3
  22.     beq.b    had\@
  23.     blt.b    low\@
  24. high\@    subq.l    #2,\3
  25.     sub.l    \3,\4
  26.     bgt.b    high\@
  27.     bra.b    had\@
  28. low\@    add.l    \3,\4
  29.     addq.l    #2,\3
  30.     ble.b    low\@
  31.     subq.l    #2,\3
  32. had\@    lsr.l    #1,\3
  33.     ENDM
  34.  
  35. ''    move.l    #896*896,d0
  36. ''    lea.l    Table,a0
  37. ''    PyTree    d0,a0,d1,d2
  38. ''    rts
  39. ''Table    incbin    "ram:pytree.table"
  40.     
  41. ; Tested with 900*900: ok,exact (goes into high cycle)
  42. ; Tested with 900*900+1: ok,same
  43. ; Tested with 895*895: ok,exact (goes into low cycle)
  44. ; Tested with 895*895+1: BAD, gives 896. correct !
  45. ; ReTested with 895*895+1: ok,gives 895
  46. ; ReTested with 895*895: ok,gives 895
  47. ; Tested with 896*896: ok,gives 896, BUT DOES THE low CYCLE! 896 is in the table! must do directly!
  48. ; ReTested with 896*896: ok,does directly.
  49. ; Post-Opt1:
  50. ; ReTested with 896*896: ok,gives 896 (no more directly,table changed.)
  51.  
  52.